﻿jQuery(function(){
	$(".collect_type,.web_type").click(function(){
		ChangeSite();
	});
	
	$("#rule_key").blur(function(){
		var key = this.value;
		var cid = $("#collect-id").val();
		
		if(key == "")
			return false;
		
		$.ajax({
			url: APP+"?"+VAR_MODULE+"=CollectRuleType&"+VAR_ACTION+"=checkKey",
			cache: false,
			data:{"key":key,"id":cid},
			success:function(data)
			{
				if(data == 1)
					$("#key-exists").hide();
				else
					$("#key-exists").show();	
			}
		});	
	});
	
	ChangeSite();
});

function ChangeSite()
{
	var ct = $(".collect_type input:checked").val();
	var wt = $(".web_type input:checked").val();

	if(ct == 1)
	{
		$(".collect_type_0").show();
		$(".collect_type_1").hide();
	}
	else
	{
		$(".collect_type_1").show();
		$(".collect_type_0").hide();
	}
	
	if(wt == 1)
	{
		$(".multi_city").each(function(i){
			if($(this).hasClass("collect_type_"+ct - 1))
				$(".multi_city").show();
		});
	}
	else
		$(".multi_city").hide();
}